<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
export default {
  name: "App",
  async created() {
    //检查用户是否登录过
    let token = localStorage.getItem("token");
    if (!token) return;
    let res = await this.axios({
      method: "post",
      url: "/v1/user/isValidateToken",
      headers: {
        Authorization: "Bearer " + token,
      },
    });
    if (res.data.statusCode == 200) {
      let user = res.data.data.userInfo;
      this.$store.commit("setUser", { user });
      this.axios({
        method: "post",
        url: "/v1/company/company-work-fav-list",
        headers: {
          Authorization: "Bearer " + localStorage.getItem("token"),
        },
      }).then((res) => {
        if (res.data.statusCode == 200) {
          this.$store.commit("setJobCollection", { jobCollection:res.data.data.result });
        } else this.$toast("获取信息失败");
      });
      this.axios({
        method: "post",
        url: "/v1/company/company-fav-list",
        headers: {
          Authorization: "Bearer " + localStorage.getItem("token"),
        },
      }).then((res) => {
        if (res.data.statusCode == 200) {
          this.$store.commit("setCompanyCollection", { companyCollection:res.data.data.result });
        } else this.$toast("获取信息失败");
      });
    }
  },
};
</script>
<style lang="scss" scoped>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  box-sizing: border-box;
}
</style>
